<?php

function __autoload($class) {
	require_once "models/" . $class . ".php";
}

session_start();

$page = "";
$user = NULL;

//var_dump($_SESSION['user']);
if (!(isset($_SESSION['login']) && $_SESSION['login'] != ""))
	$page = "dangnhap";
else {
	$page = $_GET['page'];
	if ($page == "dangnhap")
		header("Location: index.php");
	$user = $_SESSION['user'];
	$user->reConnectDatabase();
	//var_dump($user);
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Website Quản lý Điểm rèn luyện - Đại học Cần Thơ</title>
<link type="text/css" rel="stylesheet" href="styles/main.css" />
<link type="text/css" rel="stylesheet" href="styles/style.css" />
<script language="javascript" src="scripts/jquery-1.7.min.js"></script>
<script language="javascript" src="scripts/index_js.js"></script>
</head>

<body>
<div id="mainwrap">
    <div id="header"><?php include "views/LoginSuccess.php"; ?> </div>
    <div id="nav-menu"><?php include "views/Menu.php"; ?></div>
    <div id="content"><?php
	if ($page == "dangnhap")
		include "controllers/DangNhapController.php";
	else if (is_object($user)) {
		switch($page) {
			case 'bangdiem':
				include 'controllers/BangChamDiemController.php';
				break;
			case 'danhsachlop':
				include 'controllers/DanhSachLopController.php';
				break;
			case 'danhsachsinhvien':
				include 'controllers/DanhSachSinhVienController.php';
				break;
			case 'thongkechung':
				include 'controllers/ThongKeChungController.php';
				break;
			case 'thongtincanhan':
			default:
				include 'views/ThongTinCaNhan.php';
				break;
		}
	}
	?>
    </div>
	<?php include "footer.php"; ?>
</div>
</body>
</html>